package application;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;

public class OutputScreenController implements Initializable, ControlledScreen 
{
	ScreensController myController; 
	
	@FXML
	TableView<Tweets> ExportTable;
	
	@FXML
	private TableColumn<Tweets, String> ExportCountryCol;
	
	@FXML
	private TableColumn<Tweets, String> ExportProductCol;
	
	@FXML
	TableView<Tweets> ImportTable;
	
	@FXML
	private TableColumn<Tweets, String> ImportCountryCol;
	
	@FXML
	private TableColumn<Tweets, String> ImportProductCol;
	
	@FXML
	TableView<Follows> DealsWithTable;
	
	@FXML
	private TableColumn<Follows, String> DealsWithCountryC1;
	
	@FXML
	private TableColumn<Follows, String> DealsWithCountryC2;
	
	@FXML
	private Button Back;
	
	final ObservableList<Tweets> exportedData = FXCollections.observableArrayList(
			new Tweets ("France", "wine"),
			new Tweets ("Cuba", "tobacco"),
			new Tweets ("Mexico", "taquila"),
			new Tweets ("Cuba", "coffee beans"));
			
	final ObservableList<Tweets> importedData = FXCollections.observableArrayList(
			new Tweets ("Cuba", "wine"),
			new Tweets ("Mexico", "wine"),
			new Tweets ("Mexico", "tobacco"),
			new Tweets ("France", "tobacco"));
	
	final ObservableList<Follows> tradeData = FXCollections.observableArrayList(
			new Follows ("Cuba", "Mexico"),
			new Follows ("Mexico", "Cuba"),
			new Follows ("France", "Mexico"),
			new Follows ("Mexico", "France"),
			new Follows ("Cuba", "France"),
			new Follows ("France", "Cuba"));
			
			
	@Override
	public void setScreenParent(ScreensController screenParent)
	{ 
		myController = screenParent; 
	}

	
	
	@Override
	public void initialize(URL arg0, ResourceBundle arg1) 
	{
		ExportCountryCol.setCellValueFactory(new PropertyValueFactory<Tweets, String>("country"));
		ExportProductCol.setCellValueFactory(new PropertyValueFactory<Tweets, String>("product"));
		ExportTable.setItems(exportedData);
		
		ImportCountryCol.setCellValueFactory(new PropertyValueFactory<Tweets, String>("country"));
		ImportProductCol.setCellValueFactory(new PropertyValueFactory<Tweets, String>("product"));
		ImportTable.setItems(importedData);
		
		DealsWithCountryC1.setCellValueFactory(new PropertyValueFactory<Follows, String>("country1"));
		DealsWithCountryC2.setCellValueFactory(new PropertyValueFactory<Follows, String>("country2"));
		DealsWithTable.setItems(tradeData);
		
		Back.addEventHandler(ActionEvent.ACTION, new EventHandler<ActionEvent>() 
		           { 
						@Override
						public void handle(ActionEvent t) 
						{
							goToInputScreen(t);
						}
		           });
	}
	
	
	
	public void goToInputScreen (ActionEvent event)
	{
		myController.setScreen(ScreensFramework.INPUT_SCREEN);
	}

}
